<?php
defined('BASEPATH') OR exit('No direct script access allowed');


use QCloud_WeApp_SDK\Mysql\Mysql as DB;


class OrderList extends CI_Controller
{
    public function index()
    {
        $userid = $_POST['userid'];
//        $gtype_id = $_GET['gtype_id'];
//        $goods_id = $_GET['goods_id'];
//        $goods_name = $_GET['goods_name'];
//        $goods_att = $_GET['goods_att'];
//        $num = $_GET['num'];
//        $amount = $_GET['amount'];

        $zf = $_POST['zt'];
        $rows = null;
        if (1 == $zf) {
            $rows = DB::select('cc_order');
            $rows = DB::select('cc_order', ['*'], ['zt' => $zf, 'userid' => $userid]);
        } else if (2 == $zf) {
            $rows = DB::select('cc_order');
            $rows = DB::select('cc_order', ['*'], ['zt' => '9', 'userid' => $userid]);
        } else if (3 == $zf) {
            $rows = DB::select('cc_order');
            $rows = DB::select('cc_order', ['*'], ['zt' => '3', 'userid' => $userid]);
        } else if (4 == $zf) {
            $rows = DB::select('cc_order');
            $rows = DB::select('cc_order', ['*'], ['zt' => '4', 'userid' => $userid]);
        } else {
            $rows = DB::select('cc_order',['*'],['userid' => $userid]);
        }

        if (!empty($rows)) {
            $this->json([
                'code' => 0,
                'data' => $rows
            ]);
        } else {
            $this->json([
                'code' => -1,
                'error' => $rows['error']
            ]);
        }
    }
}
